import http from '@/utils/http';
import request from '@/utils/request';
/*
 *  user：账号管理
 * */

export async function login(body) {
  return http.post('/login', body);
}

export async function verifyAccount(body) {
  return http.post('/verifyAccount', body);
}

export async function sendEmailVerificationCode(body) {
  return http.post('/sendEmailVerificationCode', body);
}

export async function resetPasswordByEmailVerificationCode(body) {
  return http.post('/resetPasswordByEmailVerificationCode', body);
}

export async function info(body) {
  return http.get('/info', body);
}
export async function login1(body) {
  return http.get('/login/doLogin', body);
}

export async function getSmsCaptcha(body) {
  return http.get('/application/web/sendShortMessage', body);
}

export async function queryCurrent(params) {
  return http.get('/sys/getUser', params);
}

// 账号列表
export async function getUserList(params) {
  return http.get('/sys/user/list', params);
}

export async function getUsersById(params) {
  return http.get('/sys/user/id', params);
}

export async function addUsers(params) {
  return http.post('/sys/user/add', params);
}

export async function delUsers(params) {
  return http.postFormData('/sys/user/delete', params);
}

export async function resetPassword(params) {
  return http.postFormData('/sys/user/restPwd', params);
}

// 更新语言设置
export async function updateLanguage(language) {
  return http.post('/sys/user/updateLanguage', { language });
}

// 账号管理 停启用
export async function resetDisabled(data) {
  return http.postFormData('/sys/user/disabled', data);
}

export async function editUser(params) {
  return http.post('/sys/user/edit', params);
}

export async function getAuthTree(params) {
  return http.get('/sys/getTreeBy', params);
}
/*
 * role
 * */

export async function addRole(params) {
  return http.post('/sys/role/add', params);
}

export async function editRole(params) {
  return http.post('/sys/role/edit', params);
}

export async function getRoleList(params) {
  return http.get('/sys/getRoleList', params);
}

export async function updateRole(params) {
  return http.post('/sys/updateRole', params);
}

export async function doRemoveList(params) {
  return http.postFormData('/sys/role/delete', params);
}

export async function getRoleByRoleId(params) {
  return http.get('/sys/getRoleByRoleId', params);
}

export async function getRolesByCreateUserPage(params) {
  return http.get('/sys/role/list', params);
}

export async function fetchMenuTreeByRoleId(params) {
  return http.get('/sys/role/info', params);
}

export async function fetchMenuTreeByTenantId(params) {
  return http.get('/sys/role/menus', params);
}

// 获取绑定用户信息
export async function getBindInfo(params) {
  return http.get('/sys/user/getBindInfo', params);
}

// 获取用户列表
export async function getClientEmpty(params) {
  return http.get('/robot/getClientEmpty', params);
}


/**
 *
 * @param 角色管理 or 授权
 * @returns
 */

export async function getUserRoleList(params) {
  return http.get('/user/list', params);
}

export async function removeUserAuth(params) {
  return http.get('/user/removeAuth', params);
}

export async function postUserAuth(data) {
  return http.post('/user/auth', data);
}

export async function getUserAuthList(params) {
  return http.get('/user/authList', params);
}

// 乙方根据角色查询绑定的甲方用户
export async function getAppUserAuthList(params) {
  return http.get('/user/app/authList', params);
}

// 乙方给甲方用户配置角色
export async function postAppUserAuth(data) {
  return http.post('/user/app/auth', data);
}

// 乙方根据角色删除绑定的甲方用户
export async function removeAppUserAuth(params) {
  return http.get('/user/app/removeAuth', params);
}

// 乙方获取该企业下所有甲方用户
export async function getAllApplicationAdmin(params) {
  return http.get('/sys/user/getAllApplicationAdmin', params);
}

// 角色停启用
export async function postSysRoleDisabled(data) {
  return http.post('/sys/role/disabled', data)
}
/*
 * Authorization
 * */

export async function roleAuthorization(params) {
  return http.post('/sys/roleAuthorization', params);
}

export async function updateAuthorization(params) {
  return http.post('/sys/updateAuthorization', params);
}

export async function getRolesByCreateUser(params) {
  return http.post('/sys/getRolesByCreateUser', params);
}

export async function getMenuList(params) {
  return http.get('/sys/getMenuList', params);
}

export async function getmenusByUserId(params) {
  return http.get('/sys/getmenusByUserId', params);
}

export async function getMenus(params) {
  return http.get('/sys/getMenus', params);
}

export async function doAllSysMenu(params) {
  return http.get('/sys/getAllSysMenu', params);
}

export async function doUserMenu(params) {
  return http.get('/sys/getMenuList', params);
}

export async function fetchAuthRole(params) {
  return http.post('/sys/addRole', params);
}

export async function fetchUpdateAuthRole(params) {
  return http.post('/sys/updateRole', params);
}

/*
 * robot
 * */

export async function addRobot(params) {
  return http.post('/robot/addRobot', params);
}

export async function getRobotList(params) {
  return http.get('/robot/getRobotList', params);
}

export async function delRobot(params) {
  return http.post('/robot/delRobot', params);
}

export async function updateRobot(params) {
  return http.post('/robot/updateRobot', params);
}

/*
 * sys
 * */

export async function changeUser(params) {
  return http.post('/robot/changeUser', params);
}

export async function changeTenant(params) {
  return http.postFormData('/sys/user/changeTenant', params);
}

/**
 * 应用通讯录
 */

// 部门树
export async function getDepartment(params) {
  return http.get('/client/dept', params);
}

// 员工列表
export async function postStaffList(params) {
  return http.get('/client/employee', params);
}

// 全量同步通讯录
export async function getFullSync(params) {
  return http.get('/baseContact/fullSync', params);
}

//首页
export async function getIndexInfo(params) {
  return http.get('/index', params);
}

// 查询通讯录同步状态
export async function getFullSyncStatus(params) {
  return http.get('/baseContact/findSyncStatus', params);
}

// 取消同步
export async function doCancelSync(params) {
  return http.get('/baseContact/cancel', params);
}

//获取同步记录
export async function getSyncRecords(params) {
  return http.get('/baseContact/list', params);
}
